﻿@model ProductDetailsModel
@using Microsoft.AspNetCore.Http.Extensions
@inject SeoSettings seoSettings
@using Grand.Framework.Themes
@using Grand.Framework.UI
@inject IWorkContext workContext
@inject IThemeContext themeContext
@inject IPageHeadBuilder pagebuilder

@{
    var themeName = themeContext.WorkingThemeName;
    var supportRtl = workContext.WorkingLanguage.Rtl;
    if (supportRtl)
    {
        pagebuilder.AppendCssFileParts(ResourceLocation.Head, string.Format("~/Themes/{0}/Content/css/product/product.rtl.css", themeName));
    } else
    {
        pagebuilder.AppendCssFileParts(ResourceLocation.Head, string.Format("~/Themes/{0}/Content/css/product/product.css", themeName));
    }
}
@{
    Layout = "_ColumnsOne";

    //title, meta
    pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
    pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);

    //canonical URL
    if (seoSettings.CanonicalUrlsEnabled)
    {
        var productUrl = Url.RouteUrl("Product", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
        pagebuilder.AddCanonicalUrlParts(productUrl);
    }

    //open graph META tags
    if (seoSettings.OpenGraphMetaTags)
    {
        pagebuilder.AddHeadCustomParts("<meta property=\"og:type\" content=\"product\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"og:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"og:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"og:image\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"og:image:url\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"og:url\" content=\"" + this.Url.ActionContext.HttpContext.Request.GetEncodedUrl() + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"og:site_name\" content=\"" + Html.Encode(Model.CurrentStoreName) + "\" />");
    }

    //Twitter META tags
    if (seoSettings.TwitterMetaTags)
    {
        pagebuilder.AddHeadCustomParts("<meta property=\"twitter:card\" content=\"summary\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"twitter:site\" content=\"" + Html.Encode(Model.CurrentStoreName) + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"twitter:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"twitter:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"twitter:image\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        pagebuilder.AddHeadCustomParts("<meta property=\"twitter:url\" content=\"" + this.Url.ActionContext.HttpContext.Request.GetEncodedUrl() + "\" />");
    }
}
<!--product breadcrumb-->
@section Breadcrumb
{
    <partial name="_ProductBreadcrumb" model="Model.Breadcrumb" />
}

<vc:widget widget-zone="productdetails_after_breadcrumb" additional-data="@Model.Id"></vc:widget>
<div class="page product-details-page product-standard">
    <vc:widget widget-zone="productdetails_top" additional-data="@Model.Id"></vc:widget>
    <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id="product-details-form">
        <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">
            <b-container class="position-relative">
                <b-row>
                    <vc:widget widget-zone="productdetails_before_pictures" additional-data="@Model.Id"></vc:widget>
                    <!--product pictures-->
                    <partial name="_ProductDetailsPictures" model="Model" />
                    <vc:widget widget-zone="productdetails_after_pictures" additional-data="@Model.Id"></vc:widget>
                    <b-col xl="6" lg="6" md="7" cols="12" class="overview pl-md-3 pl-0 pr-0">
                        @if (!string.IsNullOrEmpty(Model.Flag))
                        {
                            <div class="product-label">
                                <b-badge variant="info">@Model.Flag</b-badge>
                            </div>
                        }
                        <partial name="_Discontinued" model="Model" />
                        <h1 class="generalTitle" itemprop="name">
                            @Model.Name
                        </h1>
                        <!--product reviews-->
                        @if (Model.ProductReviewOverview.AllowCustomerReviews)
                        {
                            <partial name="_ProductReviewOverview" model="Model.ProductReviewOverview" />
                        }
                        <vc:widget widget-zone="productdetails_overview_top" additional-data="@Model.Id"></vc:widget>
                        @if (!String.IsNullOrEmpty(Model.ShortDescription))
                        {
                            <div class="short-description generalMarginSupporter">
                                @Html.Raw(Model.ShortDescription)
                            </div>
                        }
                        <!--manufacturers-->
                        @if (Model.ProductManufacturers.Any())
                        {
                            <partial name="_ProductManufacturers" model="Model.ProductManufacturers" />
                        }
                        <!--availability-->
                        @if (!String.IsNullOrWhiteSpace(Model.StockAvailability) || Model.DisplayBackInStockSubscription)
                        {
                            <partial name="_Availability" model="Model" />
                        }
                        <!--SKU, MAN, GTIN, vendor-->
                        <partial name="_SKU_Man_GTIN_Ven" model="Model" />
                        <!--delivery-->
                        @if ((Model.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(Model.DeliveryDate)
                      || Model.NotReturnable || Model.AdditionalShippingCharge > 0)
                        {
                            <partial name="_DeliveryInfo" model="Model" />
                        }
                        <!--sample download-->
                        @if (Model.HasSampleDownload)
                        {
                            <partial name="_DownloadSample" model="Model" />
                        }
                        <!--product bundles-->
                        @if (Model.ProductBundleModels.Any())
                        {
                            <partial name="_ProductBundles" model="Model" />
                        }
                        <!--attributes-->
                        @{
                            if (Model.ProductAttributes.Any())
                            {
                                var dataDictAttributes = new ViewDataDictionary(ViewData);
                                dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", Model.Id);
                                <partial name="VueProductAttributes"  model="Model.ProductAttributes" view-data="dataDictAttributes" />
                            }
                        }
                        <!--warehouses-->
                        @if (Model.AllowToSelectWarehouse)
                        {
                            <partial name="_ProductWarehouses" model="Model" />
                        }
                        <!--gift card-->
                        @{
                            if (Model.GiftCard.IsGiftCard)
                            {
                                var dataDictGiftCard = new ViewDataDictionary(ViewData);
                                dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", Model.Id);
                                <partial name="_GiftCardInfo" model="Model.GiftCard" view-data="dataDictGiftCard" />
                            }
                        }
                        <!--reservation info-->
                        @if (Model.ProductType == ProductType.Reservation)
                        {
                            var dataDictReservation = new ViewDataDictionary(ViewData);
                            dataDictReservation.TemplateInfo.HtmlFieldPrefix = string.Format("reservation_{0}", Model.Id);
                            <partial name="_ReservationInfo" model="Model" view-data="dataDictReservation" />
                        }
                        <!--price & add to cart-->
                        <div class="overview-buttons generalMarginSupporter">
                            @if (Model.TierPrices.Any() && !(Model.TierPrices.Count == 1))
                            {
                                <div class="col-lg-12 px-0">
                                    <partial name="_ProductTierPrices" model="Model.TierPrices" />
                                </div>
                            }
                            <div class="col-lg-12 px-0">
                                @{
                                    var dataDictPrice = new ViewDataDictionary(ViewData);
                                    dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", Model.Id);
                                    <partial name="_ProductPrice" model="Model.ProductPrice" view-data="dataDictPrice" />
                                }
                            </div>
                            <div class="generalMarginSupporter">
                                <!--auction-->
                                @if (Model.ProductType == ProductType.Auction)
                                {
                                    var dataDictAuction = new ViewDataDictionary(ViewData);
                                    dataDictAuction.TemplateInfo.HtmlFieldPrefix = string.Format("auction_{0}", Model.Id);
                                    <partial name="_AuctionInfo" model="Model" view-data="dataDictAuction" />
                                }
                                @{
                                    var dataDictAddToWishlist = new ViewDataDictionary(ViewData);
                                    dataDictAddToWishlist.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", Model.Id);
                                    var dataDictAddToCart = new ViewDataDictionary(ViewData);
                                    dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", Model.Id);
                                }
                                <partial name="_AddToCart" model="Model.AddToCart" view-data="dataDictAddToCart" />
                                <b-btn-group class="mt-2 mb-3 w-100">
                                    @if (Model.ProductType == ProductType.SimpleProduct || Model.ProductType == ProductType.BundledProduct)
                                    {
                                        <partial name="_AddToWishlist" model="Model.AddToCart" view-data="dataDictAddToWishlist" />
                                        <partial name="_CompareProductsButton" model="Model" />
                                    }
                                    @if (Model.EmailAFriendEnabled)
                                    {
                                        <partial name="_ProductEmailAFriendButton" model="Model" />
                                    }
                                    @if (Model.AskQuestionEnabled)
                                    {
                                        <partial name="_ProductAskQuestionButton" model="Model" />
                                    }
                                </b-btn-group>
                            </div>
                        </div>
                        @if (!String.IsNullOrWhiteSpace(Model.PageShareCode))
                        {
                            <div class="col-12 product-share px-0">
                                <partial name="_ShareButton" model="Model" />
                            </div>
                        }
                        <vc:widget widget-zone="productdetails_overview_bottom" additional-data="@Model.Id"></vc:widget>
                    </b-col>
                </b-row>
            </b-container>

            <b-col cols="12" class="px-0 my-3">
                <div>
                    <b-tabs content-class="mt-3" align="center">
                        <b-tab title="@T("Products.Description")" active>
                            @Html.Raw(Model.FullDescription)
                        </b-tab>
                        @if (Model.ProductTags.Any())
                        {
                            <b-tab title="@T("Products.Tags")">
                                <partial name="_ProductTags" model="Model.ProductTags" />
                            </b-tab>
                        }
                        @if (Model.ProductSpecifications.Any())
                        {
                            <b-tab title="@T("Products.Specs")">
                                <partial name="_ProductSpecifications" model="Model.ProductSpecifications" />
                            </b-tab>
                        }
                        @if (Model.ProductReviewOverview.AllowCustomerReviews)
                        {
                            <b-tab id="review-tab" title="@T("Products.Reviews")" :active="active ? true : false">
                                @await Component.InvokeAsync("ProductReviews", new { productId = Model.Id })
                            </b-tab>
                        }
                        @if (Model.AskQuestionOnProduct)
                        {
                            <b-tab title="@T("Products.ContactUs")">
                                <partial name="_AskQuestionOnProduct" model="Model.ProductAskQuestion" />
                            </b-tab>
                        }
                    </b-tabs>
                </div>
            </b-col>
            <vc:products-also-purchased product-id="@Model.Id" product-thumb-picture-size="null"></vc:products-also-purchased>
            <vc:related-products product-id="@Model.Id" product-thumb-picture-size="null"></vc:related-products>
            <vc:similar-products product-id="@Model.Id" product-thumb-picture-size="null"></vc:similar-products>
        </div>
    </form>
    <vc:widget widget-zone="productdetails_bottom" additional-data="@Model.Id"></vc:widget>
</div>